package com.cq.hd.order.render.impl;

import com.cq.hd.order.render.OrderContext;
import com.cq.hd.order.render.OrderRenderStepEnum;
import com.cq.hd.order.render.dto.PriceDetailDto;
import com.cq.hd.product.api.TbActiveApi;
import com.cq.hd.product.api.vo.ActiveGroupBuyVo;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;


/**
 * @author Much
 * @since 2024/09/25 5:50
 */
@Component
public class GroupBuyActiveRender extends AbstractRenderStep {

    @Resource
    private TbActiveApi activeApi;

    @Override
    public OrderRenderStepEnum step() {
        return OrderRenderStepEnum.GROUP_BUY_ACTIVE;
    }

    @Override
    public void render(OrderContext orderContext) {
        Long activeId = orderContext.getActiveId();
        ActiveGroupBuyVo activeGroupBuyVo = activeApi.getGroupBuyActiveByActiveId(activeId).unpack();

        PriceDetailDto priceDetailDTO = orderContext.getPriceDetailDTO();
        priceDetailDTO.setActivePrice(activeGroupBuyVo.getGroupBuyPrice());
    }

}
